#if !defined NES_GLOBALS_INCLUDED
#include "include/nes/nes_globals.inl"
#endif


#define NES_SAVE_SQL_INCLUDED 1

stock saveAllSql(id, money, frags, hp, ap, apTp,  const weapons[32], weaponsNum) {
	new msg[128];
	formatex(msg, charsmax(msg), "%d#%d#%d#%d#%d#%d",money, frags,hp,ap,apTp, weaponsNum);
	new weapon, ammo, clip;
	for(new i=0;i<weaponsNum;i++){
		weapon = weapons[i];
		get_user_ammo(id, weapon, clip, ammo);
		format(msg, charsmax(msg), "%s#%d%#d#%d", msg, weapons[i], clip, ammo);
	}
	//nvault_set(gVault, playerKey[id], msg);
}


stock loadAllSql(id){
	new msg[128];
	new timestamp;
	if(1){
		new left[8];
		new money;
		new frags;
		new hp;
		new ap;
		new apTp;
		new weapons[32];
		new weaponsAmmo[32];
		new weaponsClip[32];
		new weaponsNum;
		
		strtok(msg,left, charsmax(left), msg, charsmax(msg), '#');
		money = str_to_num(left);
		
		strtok(msg,left, charsmax(left), msg, charsmax(msg), '#');
		frags = str_to_num(left);
		
		strtok(msg,left, charsmax(left), msg, charsmax(msg), '#');
		hp = str_to_num(left);
		
		strtok(msg,left, charsmax(left), msg, charsmax(msg), '#');
		ap = str_to_num(left);
		
		strtok(msg,left, charsmax(left), msg, charsmax(msg), '#');
		apTp = str_to_num(left);
		
		strtok(msg,left, charsmax(left), msg, charsmax(msg), '#');
		weaponsNum = str_to_num(left);
		
		if(weaponsNum){
			for(new i=0;i<weaponsNum;i++){
				strtok(msg,left, charsmax(left), msg, charsmax(msg), '#');
				weapons[i] = str_to_num(left);
				
				strtok(msg,left, charsmax(left), msg, charsmax(msg), '#');
				weaponsClip[i] = str_to_num(left);
				
				strtok(msg,left, charsmax(left), msg, charsmax(msg), '#');
				weaponsAmmo[i] = str_to_num(left);
			}
		}
		preparePlayer(id, money,frags,hp,ap,apTp,weapons, weaponsAmmo, weaponsClip, weaponsNum);
	}
}
